package com.tarena.lbs.basic.web.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.basic.web.service.BusinessService;
import com.tarena.lbs.pojo.basic.param.BusinessParam;
import com.tarena.lbs.pojo.basic.query.BusinessQuery;
import com.tarena.lbs.pojo.basic.vo.BusiStoreVO;
import com.tarena.lbs.pojo.basic.vo.BusinessVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class BusinessController {
    @Autowired
    private BusinessService businessService;

    //后台管理 查询商家列表 分页查询
    @GetMapping("/admin/basic/business/info/list")
    public Result<PageResult<BusinessVO>> businessPage(BusinessQuery query) throws BusinessException {
        PageResult<BusinessVO> voPage=businessService.businessPage(query);
        return new Result<>(voPage);
    }
    //商家入住表单提交 新增
    /*
        {
            name:wang,
            age:18
        }
     */
    @PostMapping("/admin/basic/business/info/save")
    public Result<Void> save(@RequestBody BusinessParam param)
        throws BusinessException{
        businessService.save(param);
        return Result.success();
    }
    //从活动详情 查询商家 以及 商家下的展示店铺列表
    @GetMapping("/basic/business/info/detail/{id}")
    public Result<BusiStoreVO> bizStoreDetails(@PathVariable("id") Integer id) throws BusinessException {
        return new Result<>(businessService.bizStoreDetails(id));
    }
}
